#pragma once
#include "component.h"
#include <functional>
#include <memory>

class Acceptor {
  public:
    DISALLOW_COPY_AND_MOVE(Acceptor);
    explicit Acceptor(EventLoop *loop, int port);
    ~Acceptor();

    RC AcceptConnection() const;
    void set_new_connection_callback(std::function<void(int)> const &callback);

  private:
    std::unique_ptr<Socket> socket_;
    std::unique_ptr<Channel> channel_;
    std::function<void(int)> new_connection_callback_;
};
